#include "fileops.h"
int ls_command(const char*cwd,char*result){
    DIR *dir;
    struct dirent *entry;

    // 打开目录
    dir = opendir(cwd);
    if (dir == NULL) {
        perror("opendir");
        return -1;
    }


    // 遍历目录项
    while ((entry = readdir(dir)) != NULL) {
        if(entry->d_name[0]=='.'&&entry->d_name[1]=='\0'){
            continue;
        }else if(entry->d_name[0]=='.'&&entry->d_name[1]=='.'){ 
        continue;
        }
        strcat(result,entry->d_name);
        strcat(result,"\t");
    }
    strcat(result,"\n");
    closedir(dir);
    return 0;
}


